window.addEventListener("load", function () {
	// API tab区动态渲染
	const apiData = [
		{ times: 4000, price: 1200, unitPrice: "0.3000" },
		{ times: 8000, price: 2000, unitPrice: "0.2500" },
		{ times: 40000, price: 8000, unitPrice: "0.2000" },
	];
	apiData.forEach(function (v) {
		// console.log($(".right p:nth-child(4)"));
		$(
			".right p:nth-child(4)"
		).innerHTML += `<span data-price="${v.price}" data-unitPrice="${v.unitPrice}" class="sweep">${v.times}次</span>`;
		/* $(".right p:nth-child(5)").firstElementChild.textContent = v.price;
		$(
			".right p:nth-child(5)"
		).textContent = `(约${v.unitPrice}元/次),仅限企业实名购买;`; */
	});
	// console.log($(".right p:nth-child(4)>span"));
	$(".right p:nth-child(4)>span")[1].classList.add("active");
	$(".right p:nth-child(5)").innHTML = `
		<strong>¥${$(".right p:nth-child(4) span")[1].dataset.price}</strong>
		(约${
			$(".right p:nth-child(4) span")[1].dataset.unitprice
		}元/次),仅限企业实名购买;
	`;
	// APItab激活效果;
	$(".right p:nth-child(4) span");
	$(".right p:nth-child(4) span").forEach(function (v) {
		v.addEventListener("click", function () {
			if (!this.classList.contains("default")) {
				$(".right p:nth-child(4) span").forEach(function (item) {
					item.classList.remove("active");
				});
				this.classList.add("active");
				$(".right p:nth-child(5)").innerHTML = `
					<strong>¥${this.dataset.price}</strong>
					(约${this.dataset.unitprice}元/次),仅限企业实名购买;
				`;
			}
		});
	});

	// 选项卡激活
	tab(".choose ul li", "active", ".content-left > div", "on");

	// 返回顶部
	$(".returntop");
	// 让按钮默认隐藏
	$(".returntop").style.display = "none";
	//给window添加滚动事件
	this.window.addEventListener("scroll", function () {
		// 定义变量st接根节点距离顶部的距离数值
		let st = document.documentElement.scrollTop;
		// 判断变量st是否大于500
		if (st > 500) {
			// 大于返回顶部按钮显示
			$(".returntop").style.display = "block";
		} else {
			// 不大于返回顶部按钮隐藏
			$(".returntop").style.display = "none";
		}
	});
	// 给节点绑定点击事件
	$(".returntop").addEventListener("click", function () {
		// 点击返回顶部
		window.scrollTo({ left: 0, top: 0, behavior: "smooth" });
	});

	//配置
	var config = {
		selector: "#bannerBg", //例：#bannerBg
		vx: 4, //点x轴速度,正为右，负为左
		vy: 4, //点y轴速度
		height: 2, //点高宽，其实为正方形，所以不宜太大
		width: 2,
		count: 100, //点个数
		color: "#c1c1c1", //点颜色
		stroke: "193,193,193", //线条颜色
		dist: 6000, //点吸附距离
		e_dist: 20000, //鼠标吸附加速距离
		max_conn: 10, //点到点最大连接数
	};
	//调用
	CanvasParticle(config);
});
